package com.work1;

import java.util.ArrayList;
import java.util.Collections;

public class Test {

    //如图所示:有四名学生参加注册会计师考试,
    // 表格中记录的是4名学生的考试成绩,请按照成绩将四名学生从小到大进行排名,并将结果展示出来.

    public static void main(String[] args) {
        sortStudentScore();
    }


    public static void sortStudentScore() {
        ArrayList<Student> students = new ArrayList<>();
        students.add(new Student("小亮",1,99));
        students.add(new Student("小强",2,85));
        students.add(new Student("小响",3,90));
        students.add(new Student("小勇",4,75));
        //使用集合的工具类Collections进行排序
        Collections.sort(students,  (o1, o2) -> Double.compare(o1.getScore(),o2.getScore()));
        for (Student student : students) {
            System.out.println(student);
        }
    }
}
